package com.clw.classfile.attribute.info;

import com.clw.classfile.BytesReader;

/**
 * Created by chengliwei on 2018/11/16.
 */
public class LineNumberTable extends AttributeInfo {

    private short lineNumberTableLength;
    private LineNumberInfo[] lineNumberTable;

    private class LineNumberInfo {

        private short startPc; // 字节码行号
        private short lineNumber; // java源码行号

        public LineNumberInfo(short startPc, short lineNumber) {
            this.startPc = startPc;
            this.lineNumber = lineNumber;
        }
    }

    public LineNumberTable(BytesReader reader) {
        super(reader.readInt());
        this.lineNumberTableLength = reader.readShort();
        this.lineNumberTable = new LineNumberInfo[lineNumberTableLength];
        for (int i = 0; i < lineNumberTableLength; i++) {
            lineNumberTable[i] = new LineNumberInfo(reader.readShort(), reader.readShort());
        }
    }
}
